﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FoneBuddy.LinqModel.Data;
using FoneBuddy.LinqData;
using FoneBuddy.LinqModel;

public partial class Subscription_List : System.Web.UI.Page
{
    IDataRepository _dataObject = new DataRepository();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            getSubscription();
        }
    }

    #region BindData
    private void getSubscription()
    {
        Subscription subscription;
        List<Subscription> subscriptions = new List<Subscription>();
        subscription = new Subscription(_dataObject);

        subscriptions = subscription.GetAllSubscription();

        if (subscriptions != null)
        {
            rptSubscription.DataSource = subscriptions;
            rptSubscription.DataBind();
        }
    }
    #endregion

    //#region Webmethod for edit and delete
    //[System.Web.Services.WebMethod]
    //public static string Update(string name, string amount, string duration, string id)
    //{
    //    Subscription subscription = new Subscription();
    //    IDataRepository _dataObject = new DataRepository();
    //    subscription = new Subscription(_dataObject);
    //    subscription.PlanName = name;
    //    if (id == "")
    //        subscription.Id = 0;
    //    else
    //        subscription.Id = Convert.ToInt32(id);

    //    subscription.GetSubscriptionByName();

    //    if (id != "")
    //    {
    //        if (subscription.Id != Convert.ToInt32(id) && subscription.Id != 0)
    //        {
    //            return "0";
    //        }
    //        else
    //        {
    //            subscription.Amount = Convert.ToDecimal(amount);
    //            subscription.Duration = Convert.ToInt32(duration);
    //            subscription.UpdatedDate = System.DateTime.Now;
    //            subscription.IsDeleted = false;
    //            subscription.Update();
    //            return subscription.Id.ToString();
    //        }
    //    }
    //    else
    //    {
    //        if (subscription.Id > 0)
    //        {
    //            return "0";
    //        }
    //        else
    //        {
    //            subscription.Amount = Convert.ToDecimal(amount);
    //            subscription.Duration = Convert.ToInt32(duration);
    //            subscription.CreatedDate = System.DateTime.Now;
    //            subscription.Create();
    //            return subscription.Id.ToString();
    //        }
    //    }
    //}
    //[System.Web.Services.WebMethod]
    //public static string Delete(string id)
    //{
    //    try
    //    {
    //        FoneBuddy.LinqModel.Subscription subscription = new Subscription();
    //        IDataRepository _dataObject = new DataRepository();
    //        subscription = new Subscription(_dataObject);
    //        subscription.Id = Convert.ToInt32(id);
    //        subscription.Delete();
    //        return "Deleted";
    //    }
    //    catch (Exception ex)
    //    {
    //        return "error";
    //    }

    //}
    //#endregion

}